using FluentNHibernate.Mapping;

namespace Nvigorate.Repository.Test
{
    public class PersonMap : ClassMap<Person>
    {
        public PersonMap()
        {
            Id(p => p.Id).GeneratedBy.Identity();
            Map(p => p.FirstName).Length(128);
            Map(p => p.LastName).Length(128);
            Map(p => p.Age);

            HasManyToMany(p => p.Vehicles).Table("drivers").AsBag().Cascade.SaveUpdate().Inverse();
        }
    }

    public class VehicleMap : ClassMap<Vehicle>
    {
        public VehicleMap()
        {
            Id(v => v.Id).GeneratedBy.Identity();
            Map(v => v.Make).Length(128);
            Map(v => v.Model).Length(128);
            Map(v => v.Color).Length(128);
            Map(v => v.Year);

            HasManyToMany(v => v.Drivers).Table("drivers").AsBag().Cascade.SaveUpdate();
        }
    }
}